package top.wyloop.springbatchexercise;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ItemProcessor;

/**
 * 将人名转成大写的处理程序
 * <p>
 * 实现Spring Batch框架的ItemProcessor<I, O>接口
 * I表示输入数据类型，O表示输出数据类型
 * 要实现接口的process方法
 *
 * @author Wyatt6
 * @date 2025/6/19
 */
@Slf4j
public class PersonItemProcessor implements ItemProcessor<Person, Person> {
    @Override
    public Person process(Person item) throws Exception {
        String firstName = item.firstName().toUpperCase();
        String lastName = item.lastName().toUpperCase();
        Person transformedPerson = new Person(firstName, lastName);
        log.info("Converting ({}) into ({})", item, transformedPerson);
        return transformedPerson;
    }
}
